package es.usj.apps.moviles.overlays;

import java.util.ArrayList;

import android.graphics.Canvas;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class POIOverlay extends ItemizedOverlay<OverlayItem> {

	public int tag = 0;
	private ArrayList<OverlayItem> mOverlayItems = new ArrayList<OverlayItem>();

	public POIOverlay(Drawable defaultMarker,
			ArrayList<OverlayItem> mOverlayItems) {
		super(boundCenterBottom(defaultMarker));
		this.mOverlayItems = mOverlayItems;
	}

	@Override
	protected OverlayItem createItem(int i) {
		return mOverlayItems.get(i);
	}

	@Override
	public int size() {
		return mOverlayItems.size();
	}

	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {

		super.draw(canvas, mapView, shadow);
	}
	
	public void addOverlayItem(OverlayItem item) {
		mOverlayItems.add(item);
		//doPopulate();
	}

	public void doPopulate() {
		populate();
		setLastFocusedIndex(-1);
	}

	public void setTag(int tag) {
		this.tag = tag;
	}

	public int getTag() {
		return this.tag;
	}
}
